export default {
  methods: {
    getFilterObj(processType) {
      let result = '';
      const { fromList } = this.$route.query;
      if (fromList) {
        const storeData = localStorage.getItem('FILTER_DATA');
        if (storeData) {
          const storeDataToParse = JSON.parse(storeData);
          result = storeDataToParse[processType] || '';
        }
      }
      return result;
    },
    filterObjStore(processType) {
      if (typeof this.formatParams !== 'function') {
        console.warn('无法获取列表过滤数据');
        return;
      }
      if (!processType) {
        console.warn('请传入审批模块类型');
        return;
      }
      const storeData = localStorage.getItem('FILTER_DATA') || '{}';
      const storeDataToParse = JSON.parse(storeData);
      storeDataToParse[processType] = JSON.stringify(this.formatParams());
      localStorage.setItem('FILTER_DATA', JSON.stringify(storeDataToParse));
    },
    getFinishedMessage(processType) {
      if (!processType) {
        console.warn('请传入审批模块类型');
        return;
      }
      const { fromList } = this.$route.query;
      let message = '👍太棒了，审批已全部处理完毕';
      const storeData = localStorage.getItem('FILTER_DATA');
      if (storeData && fromList) {
        const storeDataToParse = JSON.parse(storeData);
        const filterString = storeDataToParse[processType] || '{}';
        const filterObj = JSON.parse(filterString);
        const filterKeys = Object.keys(filterObj);
        const excludeKeys = ['page', 'perPage', 'tabStatus', 'sortType', 'sortName', 'notShowNoAuthTip', 'id', 'ids']; // 这些key不计入实际筛选
        const isFilter = filterKeys.some(key =>
          !excludeKeys.includes(key) && (key !== 'dynamicFilter' || filterObj['dynamicFilter'] !== '[]') &&
          (filterObj[key] || filterObj[key] === 0)
        );
        if (isFilter) message = '当前列表筛选的审批已处理完毕，可返回列表继续处理其他审批';
      }
      return message;
    }
  }
};
